#ifndef PH_API_WIDGET_H__
#define PH_API_WIDGET_H__

#include "common.h"
#include <structmember.h>

//=====================================================================
//                    Widget - analog of PtWidget_t
//=====================================================================
/** 
 * @brief Widget type
 */
typedef struct
{
  PyObject_HEAD
  PtWidget_t *widget, ///< To store pointer to real widget
             *parent; ///< Pointer to parent widget

  PtWidgetClassRef_t *widget_class; ///< For calling PtCreateWidget
} Widget;

/// For passing parametres to callback
typedef struct
{
  PyObject *callable, *args;
} WidgetCallbackData;

static void Widget_dealloc (Widget* self);
static PyObject* Widget_new (PyTypeObject* type, PyObject* args, PyObject* kwds);
static int Widget_init (Widget* self, PyObject* args); 

/// To get resources
static PyObject* Widget_get_arg (Widget* self, PyObject* args);

/// To set callbacks
static PyObject* Widget_set_callback (Widget* self, PyObject* args);

/// To set resources
static PyObject* Widget_set_arg (Widget* self, PyObject* args);

/// Analog of PtCreateWidget for concrete widget
static PyObject* Widget_create (Widget* self);

/// Analog of PtRelizeWidget for concrete widget
static PyObject* Widget_realize (Widget* self);

/// To provide Pt_DEFAULT_PARENT
static PyObject* Widget_set_default_parent (Widget* self);

/// To provide Pt_NO_PARENT
static PyObject* Widget_set_no_parent (Widget* self);

/// To provide real parent
static PyObject* Widget_set_parent (Widget* self, PyObject* args);

//=====================================================================
//            Common functions to manipulate callbacks
//=====================================================================

typedef enum
{
  eNoneCallback,
  eSender,
  ePostMenu
} CallbackType;

static CallbackType find_callback_type (const char* repr);

#endif // PH_API_WIDGET_H__

